package com.xxd.spring.boot.demo.zhuhongbing.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xxd.spring.boot.demo.zhuhongbing.entity.Classes;
import com.xxd.spring.boot.demo.zhuhongbing.entity.Teacher;
import com.xxd.spring.boot.demo.zhuhongbing.service.TeacherService;
import com.xxd.spring.boot.demo.zhuhongbing.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/teacher")
public class TeacherController {
    @Autowired
    private TeacherService teacherService;
    @RequestMapping("/add")
    public Result add(@RequestBody Teacher teacher){
        teacherService.add(teacher);
        return new Result().success();
    }
    @RequestMapping("/update")
    public Result update(@RequestBody Teacher teacher){
        teacherService.updateById(teacher);
        return new Result().success();
    }
    @RequestMapping("/delete/{id}")
    public Result delete(@PathVariable("id") int id){
        teacherService.deleteById(id);
        return new Result().success();
    }
    @RequestMapping("/listPage")
    public Result listPage(Page page, @RequestParam Map<String,Object> params){
        IPage<Teacher> resPage=teacherService.listPage(page,params);
        return new Result().success().setData(resPage);
    }
}
